﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string doIt = "here we go";
            System.Text.UnicodeEncoding toByte = new System.Text.UnicodeEncoding();
            byte[] byteMe = toByte.GetBytes(doIt);
            //beginEncryption(byteMe);
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
            byte[] encrypted = rsa.Encrypt(byteMe, false);
            for (int i=0; i < encrypted.Length; i++ )
            {
                Console.Write(encrypted[i]);
            }
            Console.WriteLine();
           // string temp = toByte.GetString(encrypted,0, encrypted.Length);
           // Console.WriteLine(temp);
            byte[] decrypted = rsa.Decrypt(encrypted,false);
            string temp = toByte.GetString(decrypted,0, decrypted.Length);
            Console.WriteLine(temp);
           

            Console.ReadLine();
        }

        private void beginEncryption(byte[] input)
        {
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
            byte[] encrypted = rsa.Encrypt(input, true);
            Console.WriteLine(encrypted);
        }
    }
}
